/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-20 16:24:51
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-20 21:12:30
 */
import 'package:flutter_data_center/model/attendance/grade_attendance_model.dart';
import 'package:flutter_data_center/model/attendance/school_attendance_model.dart';
import 'package:flutter_data_center/model/common/menu_model.dart';
import 'package:flutter_data_center/net/dio_utils.dart';
import 'package:get/get.dart';

class SchoolAttendanceController extends GetxController {
  // 迟到
  int _late = 0;
  int get late => _late;
  int _total = 0;
  int get total => _total;
  // 缺卡
  int _personal = 0;
  int get personal => _personal;
  // 早退
  int _leave = 0;
  int get leave => _leave;
  // 年级列表
  List<Grades> _list;
  List<Grades> get list => _list;
  void getSchoolStatistics() async {
    _list = [];
    ResponseInfo responseInfo = await DioUtils.instance.getRequest(
      url: HttpHelper.schoolStudentAttendanceStatistics,
    );
    if (responseInfo.success) {
      var data = responseInfo.data;
      _late = data['late'];
      _total = data["total"];
      _personal = data['personal'];
      _leave = data['leave'];
      for (var item in data['grades']) {
        _list.add(Grades.fromJson(item));
      }

      update();
    }
  }

  // 菜单
  List<MenuModel> _menus = [
    MenuModel("一", "one"),
    MenuModel("二", "two"),
    MenuModel("三", "three"),
    MenuModel("四", "four"),
    MenuModel("五", "five"),
    MenuModel("六", "six"),
  ];
  List<MenuModel> get menus => _menus;
}
